package com.baselib.libnetwork.net.request;

import com.baselib.libnetwork.net.utils.HttpUtils;

import okhttp3.Request;
import okhttp3.Request.Builder;
import okhttp3.RequestBody;

/**
 * @author lixuce
 * @version v1.0
 * @description
 * @since 2017/10/29
 */

public class GetRequest<T> extends CustomRequest<T, GetRequest<T>> {
    public GetRequest(String url) {
        super(url);
    }

    @Override
    public GetRequest<T> retryCount(int retryCount) {
        return super.retryCount(1);
    }

    @Override
    protected RequestBody generateRequestBody() {
        return null;
    }


    @Override
    public Request generateRequest(RequestBody requestBody) {
        url = HttpUtils.createUrlFromParams(BaseUrl, params.urlParamsMap);
        Builder requestBuilder = new Builder();
        requestBuilder.addHeader("content-type","application/x-www-form-urlencoded");
        requestBuilder = HttpUtils.appendHeaders(requestBuilder, headers);
        return requestBuilder.get().url(url).tag(tag).build();
    }
}
